test: add golden files and RunWithSuggestedFixes for 3 autofix linters#43376
Conversation
…r 3 linters Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…contains, sprintfint, stringreplaceminusone Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
🤖 PR Triage — Run §28706384347
Score breakdown: impact 22 + urgency 12 + quality 14 Adds golden files and
|
There was a problem hiding this comment.
Pull request overview
This PR strengthens linter autofix testing by switching three analyzers’ tests to validate their SuggestedFix text edits via golden files, rather than only validating diagnostic locations/messages.
Changes:
- Added
.goldenfixtures forstringsindexcontains,sprintfint, andstringreplaceminusoneto assert exact post-fix output. - Updated the three linter tests to use
analysistest.RunWithSuggestedFixesso suggested fixes are exercised and verified. - Kept analyzer implementations unchanged; changes are limited to test harness + fixtures.
Show a summary per file
| File | Description |
|---|---|
| pkg/linters/stringsindexcontains/testdata/src/stringsindexcontains/stringsindexcontains.go.golden | Golden output validating the strings.Index(...) containment comparisons are rewritten to strings.Contains forms. |
| pkg/linters/stringsindexcontains/stringsindexcontains_test.go | Switches test runner to RunWithSuggestedFixes to verify fixes against the golden file. |
| pkg/linters/stringreplaceminusone/testdata/src/stringreplaceminusone/stringreplaceminusone.go.golden | Golden output validating strings.Replace(..., -1) is rewritten to strings.ReplaceAll(...). |
| pkg/linters/stringreplaceminusone/stringreplaceminusone_test.go | Switches test runner to RunWithSuggestedFixes to verify fixes against the golden file. |
| pkg/linters/sprintfint/testdata/src/sprintfint/sprintfint.go.golden | Golden output validating fmt.Sprintf("%d", x) is rewritten to strconv.Itoa(x) for int. |
| pkg/linters/sprintfint/sprintfint_test.go | Switches test runner to RunWithSuggestedFixes to verify fixes against the golden file. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Low
|
@copilot please run the
|
Ran the
No unresolved review threads. Branch is up to date with the pushed commits. PR is ready for a human to re-trigger CI and merge. |
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. |
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
Ran
No unresolved review threads. PR is ready for a human to re-trigger CI and merge. |
🤖 PR Triage — Run §28715668077
Carry-over from prior run. Previously draft, now undrafted. Design Decision Gate requires ADR. Batch with other low-risk test PRs.
|
|
@copilot please run the
|
…erification-gap Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…erification-gap Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Branch refreshed with latest main ( |
|
@copilot please run the Run: https://github.com/github/gh-aw/actions/runs/28718358099
|
Completion summary for maintainers
What this PR does: Switches 3 linter tests ( Hand-off: Re-trigger CI (close/reopen, |
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
@copilot please run the
|
Completion summary for maintainers
Hand-off: Re-trigger CI (close/reopen, |
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
@copilot please run the
|
The ADR file is already committed on the branch at A maintainer needs to add the following line to the PR body (e.g. after the "No production analyzer code changed." line): Once the PR body is updated the ADR gate can be re-triggered. Local validation remains fully green; no code changes are needed. Summary:
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
#43376) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
🎉 This pull request is included in a new release. Release: |
3 of 9
SuggestedFix-emitting linters (stringsindexcontains,sprintfint,stringreplaceminusone) usedanalysistest.Run, which only validates diagnostic positions/messages — never the actual text edits. Their fix builders were completely unexercised.Changes
Golden files added for each linter capturing exact post-fix source:
stringsindexcontains: all 6 comparison forms + 4 yoda variants →strings.Contains/!strings.Containssprintfint:fmt.Sprintf("%d", x)→strconv.Itoa(x)(int variable and literal)stringreplaceminusone:strings.Replace(..., -1)→strings.ReplaceAll(...)(literal and named constant)Test entrypoints switched from
analysistest.Run→analysistest.RunWithSuggestedFixes, matching the pattern already used byfprintlnsprintf,lenstringzero,tolowerequalfold, etc.No production analyzer code changed.